package code.structure.module.user.view
{
	import code.structure.manager.font.FontManager;
	import code.structure.manager.loader.DllLoaderManager;
	import code.tools.commponents.Alignment;
	import code.tools.commponents.Component;
	import code.tools.commponents.Helpers;
	import code.tools.commponents.StageAligner;
	import code.untils.SWFNameConst;
	import code.untils.UiNameConst;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.text.TextField;

	/**
	 *用户信息界面 
	 * @author liangqian
	 * 
	 */	
	public class UserView extends Component
	{
		private var _levelTf:TextField;
		private var _coinTf:TextField;
		private var _energyTf:TextField;
		private var _diamondTf:TextField;
		public function UserView(parent:DisplayObjectContainer)
		{
			super(parent);
		}
		
		override protected function addChildren():void
		{
			super.addChildren();
			
			var _view:Sprite = new (DllLoaderManager.getInstance().getUIMaterial(SWFNameConst.USER_PANEL,'userView')as Class)as Sprite;
			addChild(_view);
			
			var coinArea:Sprite = _view.getChildByName('coinArea')as Sprite;
			_coinTf = Helpers.processTf(coinArea,'coinValue_text','',FontManager.getInstance().embeddedFontAName,true,true);
			
			var levelArea:Sprite = _view.getChildByName('expArea')as Sprite;
			_levelTf = Helpers.processTf(levelArea,'levelValue_text','',FontManager.getInstance().embeddedFontAName,true,true);
			
			var diamondArea:Sprite = _view.getChildByName('diamondArea')as Sprite;
			_diamondTf = Helpers.processTf(diamondArea,'diamondValue_text','',FontManager.getInstance().embeddedFontAName,true,true);
			
			var energyArea:Sprite = _view.getChildByName('energyArea')as Sprite;
			_energyTf = Helpers.processTf(energyArea,'energyValue_text','',FontManager.getInstance().embeddedFontAName,true,true);
			
			stageAligner = new StageAligner(Alignment.TOP_LEFT,25,7);
		}
		
		override protected function init():void
		{
			setSize(809,48);
			super.init();
		}
		
		/**
		 *更新用户等级 
		 * @param v
		 * 
		 */		
		public function updateLevel(v:uint):void
		{
			_levelTf.text = v+'';
		}
		/**
		 * 更新用户金币
		 * @param v
		 * 
		 */		
		public function updateCoin(v:uint):void
		{
			_coinTf.text = v+'';
		}
	}
}